package cn.edu.sdu.order.backend.controller;

import cn.edu.sdu.order.backend.annotation.NeedSwagger;
import cn.edu.sdu.order.backend.dto.GoodsDTO;
import cn.edu.sdu.order.backend.model.ResultContext;
import cn.edu.sdu.order.backend.service.GoodsService;
import cn.edu.sdu.order.backend.vo.GoodsVO;
import cn.edu.sdu.order.backend.vo.SystemVO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "货物")
@RequestMapping("goods")
@NeedSwagger
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @PostMapping("create")
    public ResultContext create(@RequestBody GoodsDTO goodsDTO) {
         return  ResultContext.returnSuccess(goodsService.create(goodsDTO));
    }

    @GetMapping("list")
    public ResultContext list(String userId) {
        return ResultContext.returnSuccess(goodsService.list(userId));
    }

    @GetMapping("get")
    public ResultContext get(String orderCode) {
        return ResultContext.returnSuccess(goodsService.get(orderCode));
    }

    @GetMapping("delete")
    public ResultContext delete(String goodsCode, Integer userType) {
        return ResultContext.returnSuccess(goodsService.delete(goodsCode, userType));
    }

    @GetMapping("update")
    public ResultContext update(String goodsCode) {
        return ResultContext.returnSuccess(goodsService.update(goodsCode));
    }
}
